/*
** init.c for lol in /home/phand/exotest/tek2/prog-elem/trade/trade-42
** 
** Made by david phan
** Login   <phan_d@epitech.net>
** 
** Started on  Fri Jun  1 18:33:22 2012 david phan
** Last update Fri Jun  1 19:17:54 2012 david phan
*/

#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <strings.h>
#include <stdlib.h>

#include "h_trade.h"

#define BUFFER_SIZE	512

void		init_trade(t_trade *trade)
{
  char		buff[BUFFER_SIZE];
  char		*sub;
  int		end;

  bzero(buff, BUFFER_SIZE);
  end = read(0, buff, BUFFER_SIZE);
  buff[end] = '\0';
  sub = strtok(buff, "\n");
  trade->start_money = atoi(sub);
  sub = strtok(NULL, "\n");
  trade->total_days = atoi(sub);
  sub = strtok(NULL, "\n");
  trade->current_auction = atoi(sub);
  trade->current_money = trade->start_money;
  trade->current_day = 1;
  trade->nb_auction = 0;
}

void		init_etude(t_etude *etude)
{
  etude->val_max = 0;
  etude->val_min = 0;
  etude->freq = 0;
  etude->moy = 0;
  etude->current_day = 1;
  etude->tot_action = 0;
}
